#include<iostream>
#include<unistd.h>
#include<signal.h>
#include<stdlib.h>

using namespace std;

int n = 0;
void handler(int signo)
{
    n = alarm(0);
    cout << "alarm: " << n << endl;
    exit(0);
}

int main()
{
    signal(14,handler);
    alarm(30);
    while(1)
    {
        cout<<"pid:"<< getpid()<<endl;
        sleep(1);
    }
    return 0;
}
